#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn = 1e5+10;
long long hi[maxn];
long long lw[maxn];
long long lsum[maxn];
bool cmp(long long a,long long b)
{
	return a>b;
}
int main()
{
	long long n,d,m;
	cin>>n>>d>>m;
	int cnth = 0;
	int cntl = 0;
	for(int i = 1;i<=n;i++)
	{
		long long x;
		cin>>x;
		if(x>m) hi[++cnth] = x;
		else lw[++cntl] = x;
	}
	sort(hi+1,hi+1+cnth,cmp);
	sort(lw+1,lw+1+cntl,cmp);
	lsum[0] = 0;
	for(int i = 1;i<=cntl;i++)
	{
		lsum[i] = lsum[i-1]+lw[i];
	}
//	printf("%d %d\n",lw[1],lw[2]);
	long long ans = 0;
	int flagh = 1;
	int flagl = 0;
	long long tie = min(d+1,n);
	for(int i = 1;i<=n;)
	{
		if((lsum[flagl+tie]-lsum[flagl])>hi[flagh]) 
		{
			ans += (lsum[flagl+d]-lsum[flagl]);
			printf("*****%d %d\n",ans,tie);
			flagl += tie;
			i = flagl;
		}
		else 
		{
			printf("**********\n");
			ans += hi[flagh];
			flagh++;
			i = i+3;
			long long t = (n-3);
			tie = min(t,d+1);
			printf("%d\n",tie);
		}
	}
	printf("%d\n",ans);
}
